<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo C('site_name');?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/statics/css/style.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/statics/js/calendar/calendar-blue.css"/>

<script type="text/javascript" src="__PUBLIC__/statics/js/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/jquery/plugins/formvalidator.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/jquery/plugins/formvalidatorregex.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/jquery/plugins/jquery.imagePreview.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="__PUBLIC__/statics/js/common.js"></script>


<script type="text/javascript">
	$(document).ready(function(){
		$("#submit").click(function(){
			$("#nums").text('0');
			$("#per").text('0%');
			$("#tips").show();
			if($("#cid").val()==0){
			  	alert('请选择商品分类');
			   	return false;
			}
			if($("#urls").val()==0){
			  	alert('请填写商品连接');
			   	return false;
			}
			var seller_id=$("#seller_id").text();
			var cid=$("#cid").val();
			var urls=$("#urls").val().split("\n");
			var i=0;
			var nums=0;
			var per='0%';
			var len=urls.length;
			bench();
		    function bench(){
			    $.post("<?php echo u('Items/betchadd');?>", { seller_id:seller_id, cid: cid, urls: urls[i] }, function(data){
			    	if(data.data){
			    		nums++;
			    	}
					$("#nums").text(nums);
			    	i++;
			    	per=Math.floor(i/len*1000)/10+'%';
					$("#per").text(per);
				    if(i<len){
					    bench();
				    }
			    },"json");
		    }
		});	
	
		$("#loading").ajaxStart(function(){
			$(this).show();
			$("#submit").hide();
		});
	
		$("#loading").ajaxStop(function(){
			$(this).hide();
			$("#submit").show();
		});
	});
</script>

</head>
<body>
<form action="<?php echo U('Items/betchadd');?>" method="post" name="myform" id="myform"  enctype="multipart/form-data" style="margin-top:10px;">
    <div class="pad-10">
        <div class="col-tab">
            <ul class="tabBut cu-li">
                <li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',1,1);">基本信息</li>
            </ul>
            <div id="div_setting_1" class="contentList pad-10">
            <div class="explain-col">
					&nbsp;&nbsp;&nbsp;&nbsp;注：一行一个商品的详细链接地址,如：<br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;<b style="color:red;">http://detail.tmall.com/item.htm?spm=a1z10.1.3-17827210533.2.nVbrh7&id=13045523063&</b><br/>
					&nbsp;&nbsp;&nbsp;&nbsp;<b style="color:red;">http://detail.tmall.com/item.htm?spm=a1z10.1.3-17827210533.2.nVbrh7&id=13045523063&</b><br/>
					&nbsp;&nbsp;&nbsp;&nbsp;<b style="color:red;">......</b><br/>
					&nbsp;&nbsp;&nbsp;&nbsp;<b style="color:red;">http://detail.tmall.com/item.htm?spm=a1z10.1.3-17827210533.2.nVbrh7&id=13045523063&</b><br/>
					
				</div>
                <table>
                    <tr>
                        <th width="120">商品归类 :</th>
                        <td><select name="cid" id="cid">
                                <option value="0">--选择分类--</option>
                                <?php if(is_array($cate_list['parent'])): $i = 0; $__LIST__ = $cate_list['parent'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><option pid="0" value="<?php echo ($val["id"]); ?>" <?php if($items['cid'] == $val['id']): ?>selected="selected"<?php endif; ?>><?php echo ($val['name']); ?></option>
                                <!--<?php if(!empty($cate_list['sub'][$val['id']])): if(is_array($cate_list['sub'][$val['id']])): $i = 0; $__LIST__ = $cate_list['sub'][$val['id']];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sval): $mod = ($i % 2 );++$i;?><option value="<?php echo ($sval["id"]); ?>" disabled="disabled"<?php if($items['cid'] == $sval['id']): ?>selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo trim($sval['name']);?></option>
                                        	<?php if(is_array($cate_list['sub'][$sval['id']])): $i = 0; $__LIST__ = $cate_list['sub'][$sval['id']];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$ssval): $mod = ($i % 2 );++$i;?><option value="<?php echo ($ssval["id"]); ?>" <?php if($cate_id == $ssval['id']): ?>selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($ssval["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; endif; ?>--><?php endforeach; endif; else: echo "" ;endif; ?>
                            </select></td>
                    </tr>
                    <tr>
                    	<th>网址URL：</th>
                        <td>
                			<textarea name="urls" id="urls" style="height:200px;width:600px;"><?php echo ($urls); ?></textarea>        
                        </td>
                    </tr>                   
                </table>
                <div id="seller_id" style="display:none;"><?php echo ($seller_id); ?></div>
            </div>
            <div class="btn">
                <input type="button" name="submit" id="submit" value="提交"  class="button" />
                <span id="loading" style="display:none;">正在采集，请稍后！<img src="__PUBLIC__/statics/images/ajax_loading.gif"/></span>
                <span id="tips" style="display:none;">共 <b id="nums" style="color:red;">0</b> 件商品添加到数据库，完成进度 <b id="per" style="color:red;">0%</b> ！</span>
            </div>
        </div>
    </div>
</form>
</body>
</html>